www.gusucode.com > 7波段参数均衡器源码程序 > 7波段参数均衡器源码程序/code/Parametric EQ/shelvingEQ.m

    function [Hd]=shelvingEQ(fc,g,type)

fs=44100;

if strcmp(type,'LP')==1
    g=10^(g/20);
    if g >= 1
        a1=-0.5*tan(pi*(fc/fs-0.25));
    else
        a1=-0.5*tan(pi*(fc/fs*1/g-0.25));
    end
    b0t=0.25-0.5*a1;
    b2=0;
    a2=0;
    b0=0.5+(g-1)*b0t;
    b1=-a1+(g-1)*b0t;

    % SOS Form
    b=2*[b0 b1 b2];
    a=[1 -2*a1 -2*a2];
    [sos,g]=tf2sos(b,a);
    Hd=dfilt.df1sos(sos,g);
end

if strcmp(type,'HP')==1
    g=10^(g/20);
    if g >= 1
        a1=-0.5*tan(pi*(fc/fs-0.25));
    else
        a1=-0.5*tan(pi*(fc/fs*g-0.25));
    end
    b0t=0.25+0.5*a1;
    b2=0;
    a2=0;
    b0=0.5+(g-1)*b0t;
    b1=-a1-(g-1)*b0t;

    % SOS Form
    b=2*[b0 b1 b2];
    a=[1 -2*a1 -2*a2];
    [sos,g]=tf2sos(b,a);
    Hd=dfilt.df1sos(sos,g);
end